<template>
  <div>
    <div class="email_desc" v-if="isRander">
      <!-- 头部 -->
      <my-header :left="true" :title="game_data.title">
        <!-- 插入 右侧icon -->
        <template class="right_icon" #right_icon>
          <van-popover  v-model="showPopover" theme="dark" trigger="click" placement="bottom-end" >
            <!-- 第一行 首页 -->
            <van-row @click="showPopover=false;$router.push('/home');">
              <!-- 图标部分 -->
              <van-col sapn="4" offset="4">
                <span class="iconfont icon-shouye"></span>
              </van-col>
              <!-- 文字部分 -->
              <van-col sapn="15" offset="1">
                <span class="icon_font">首页</span>
              </van-col>
            </van-row>
            <!-- 第二行 消息-->
            <van-row  @click="showPopover=false;$router.push('/message');">
              <!-- 图标部分 -->
              <van-col sapn="4" offset="4">
                <span class="iconfont icon-youjian"></span>
              </van-col>
              <!-- 文字部分 -->
              <van-col sapn="15" offset="1">
                <span class="icon_font">消息</span>
              </van-col>
            </van-row>
            <!-- 第三行 我的收藏-->
            <van-row  @click="showPopover=false;$router.push('/collection');">
              <!-- 图标部分 -->
              <van-col sapn="4" offset="4">
                <span class="iconfont icon-shoucang1"></span>
              </van-col>
              <!-- 文字部分 -->
              <van-col sapn="15" offset="1">
                <span class="icon_font">收藏</span>
              </van-col>
            </van-row>
            <template #reference>
              <span class="iconfont icon-gengduo"></span>
            </template>
          </van-popover>
        </template>
      </my-header>
      <!-- 邮件信息展示部分 -->
      <div class="email_info">
        <!-- 邮件标题部分 -->
        <div class="email_title">
          {{game_data.email_data.title}}
        </div>
        <!-- 邮件日期 -->
        <div class="email_date">
          {{formatDate(game_data.email_data.timer)}}
        </div>
        <!-- 邮件内容部分 -->
        <div class="email_count">
          {{game_data.email_data.count}}
        </div>
      </div>
      <!-- 账号信息展示部分 -->
      <div class="gameinfo">
        <van-row>
          <show-in-fo
          class="skin_info"
          v-for="(item,index) of game_data.gameid"
          :key="item.gameid"
          :game_data_index="index" 
          :game_data="game_data"
          ></show-in-fo>
        </van-row>
      </div>
    </div>
    <!-- 加载 -->
    <div v-if="!isRander">
      <van-loading class="mt60" size="0.24rem" vertical>数据加载中...</van-loading>
    </div>
  </div>
</template>
<script>
import MyHeader from "../../common/Header";
import ShowInFo from "../../Home/components/ShowInFo";
export default {
  name:"EmailDesc",
  created(){
    this.eid = this.$route.query.id;
    this.getEmail_data();
  },
  components:{
    MyHeader,
    ShowInFo
  },
  computed: {
    // 格式化 时间戳
    formatDate(){
      return function(val){
        let now = new Date(val*1000);
        let year=now.getFullYear(); 
        let month=now.getMonth()+1; 
        let date=now.getDate();
        let house = now.getHours();
        let min = now.getMinutes();
        let sec = now.getSeconds();
        let str = year+"-"+month+"-"+date+" "+house+':'+min+":"+sec+"";
        return str;
      }
    }
  },
  data() {
    return {
      eid:"",// 当前显示的邮件EID
      showPopover:false,
      game_data:null,// 请求到的 邮件 及 游戏账号数据
      isRander:false,// 阻止渲染
    }
  },
  methods: {
    // 获取当前邮件数据
    async getEmail_data(){
      this.isRander = false;
      const {data : res} = await this.$http.get("emaildesc",{params:{eid:this.eid}});
      this.game_data = res.data;
      this.isRander = true;
      console.log(res);
    },
  },
}
</script>
<style lang="less" scoped>
.van-popover{
  .van-row{
    width: 1rem;
    font-size: 0.15rem;
    height: 0.38rem;
    border-top: 0.01rem solid #3F3E48;
    line-height: 0.35rem;
  }
}
.email_desc{
  padding-top: 0.4rem;
  font-size: 0.14rem;
  border-top: 0.01rem solid #F6F6F6;
}
.email_info{
  padding: 0rem 0.1rem;
  background-color: #FFF;
  div{
    margin: 0.05rem 0rem;
  }
  .email_count{
    text-align: left;
    margin-top: 0.1rem;
    line-height: 0.24rem;
    padding-bottom: 0.1rem;
  }
  .email_title{
    text-align: center;
    padding-top: 0.08rem;
  }
  .email_date{
    text-align: center;
    font-size: 0.12rem;
    color: #888888;
  }
}
.gameinfo{
  margin-top: 0.06rem;
}
</style>